#ifndef SIMPLE_NAV_CLIENT_HPP_
#define SIMPLE_NAV_CLIENT_HPP_

#include <chrono>
#include <memory>
#include <string>

#include "rclcpp/rclcpp.hpp"
#include "rclcpp_action/rclcpp_action.hpp"
#include "nav2_msgs/action/navigate_to_pose.hpp"
#include "geometry_msgs/msg/pose_stamped.hpp"

class SimpleNavClient : public rclcpp::Node
{
public:
    using NavigateToPose = nav2_msgs::action::NavigateToPose;
    using GoalHandleNavigateToPose = rclcpp_action::ClientGoalHandle<navigatetopose>;

    explicit SimpleNavClient(const rclcpp::NodeOptions & options = rclcpp::NodeOptions());

    // 发送导航目标
    bool sendGoal(double x, double y, double yaw);

    // 等待导航完成
    bool waitForResult(std::chrono::seconds timeout = std::chrono::seconds(60));

private:
    // 目标响应回调
    void goal_response_callback(const GoalHandleNavigateToPose::SharedPtr & goal_handle);

    // 反馈回调
    void feedback_callback(
      GoalHandleNavigateToPose::SharedPtr,
      const std::shared_ptr<const navigatetopose::feedback=""> feedback);

    // 结果回调
    void result_callback(const GoalHandleNavigateToPose::WrappedResult & result);

    rclcpp_action::Client<navigatetopose>::SharedPtr action_client_;
    GoalHandleNavigateToPose::SharedPtr goal_handle_;
    bool goal_result_available_;
    bool goal_succeeded_;
};

#endif  // SIMPLE_NAV_CLIENT_HPP_</navigatetopose></const></navigatetopose></string></memory></chrono>